﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace OnlineDigitalCameraWebsite.Class
{
    public class InvoiceItem
    {

        #region Properties
        private ProductCart _invoiceItemProduct = new ProductCart();

        private string _invoiceId = "";
        /// <summary>
        /// SessionId unless pulling database ID
        /// </summary>
        public string InvoiceId
        {
            get
            {
                return _invoiceId;
            }
            set
            {
                _invoiceId = value;
            }
        }

        public int ProductId
        {
            get
            {
                return _invoiceItemProduct.ProductId;
            }
            set
            {
                 _invoiceItemProduct = new ProductCart(value, _productCategory);
                //_invoiceItemProduct = new ProductCart(value);
            }
        }

        public string ProductName
        {
            get
            {
                return _invoiceItemProduct.Name;
            }
        }

         
        private int _quantity = 0;
        public int Quantity
        {
            get
            {
                return _quantity;
            }
            set
            {
                _quantity = value;
            }
        }

        private string _image = "";
        public string Image
        {
            get
            {
                return _image;
            }
            set
            {
                _image = value;
            }
        }

       
        public decimal Price
        {
            get
            {
                return _invoiceItemProduct.Price * Quantity;
            }
        }

     

        public decimal UnitPrice
        {
            get
            {
                return _invoiceItemProduct.Price;
            }
        }


        private string _productCategory;
        public string ProductCategory
        {
            get
            {
                return _productCategory;
            }
            set
            {
                _productCategory = value;
            }
        }
        #endregion

        public InvoiceItem()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public InvoiceItem(string invoiceId, int productId, int quantity, string _im, string category)
        {
            this.InvoiceId = invoiceId;
            this._productCategory = category;
            this.Quantity = quantity;
            this.Image = _im;
            this.ProductId = productId;
           
        }

        public void UpdateQuantity(int quantity)
        {
            this.Quantity = quantity;
        }

        public void AddToQuantity(int quantity)
        {
            this.Quantity += quantity;
        }

    }
}